<?php
session_start();
 if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
  echo "<link href='style.css' rel='stylesheet' type='text/css'>
 <center>Untuk mengakses modul, Anda harus login <br>";
  echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
include "../../../config/koneksi.php";

$module=$_GET[module];
$act=$_GET[act];


// Kirim SMS
if ($module=='sms' AND $act=='sendsms'){
	$isi = $_POST[isi];
	$replist = $_POST[rec];
	$fr = $_POST[freeno];
	
	if(!empty($isi) || !empty($replist) || !empty($fr)) {
		for($i=0;$i<sizeof($replist);$i++) {
			$v = $replist[$i];
			exec('c:\xampp\htdocs\bosms\gammu\gammu-smsd-inject.exe -c c:\xampp\htdocs\bosms\gammu\smsdrc EMS '.$v.' -text "'.$isi.'"');
			//mysql_query("INSERT INTO outbox(InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded) VALUES(NOW(),NOW(),'$v','$isi')");
			//mysql_query("INSERT INTO outbox VALUES(NOW(),NOW(),NOW(),NULL,'$v','Default_No_Compression',NULL,'0','$isi',NULL,'true','-1',NULL,'','yes','')");
		}
		if(!empty($fr)) {
			exec('c:\xampp\htdocs\bosms\gammu\gammu-smsd-inject.exe -c c:\xampp\htdocs\bosms\gammu\smsdrc EMS '.$fr.' -text "'.$isi.'"');
			//mysql_query("INSERT INTO outbox(InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded) VALUES(NOW(),NOW(),'$fr','$isi')");
			//mysql_query("INSERT INTO outbox VALUES(NOW(),NOW(),NOW(),NULL,'$fr','Unicode_Compression',NULL,'0','$isi',NULL,'true','-1',NULL,'','yes','')");
		}
	}
  //$msg = "Pengiriman SMS Berhasil";
  header('location:../../media.php?module='.$module.'&msg='.$msg);
}

// Kirim Pesan via SMS
elseif ($module=='sms' AND $act=='sendmsg'){
	$isi = $_POST[pesan];
	$replist = $_POST[rec];
	
	if(!empty($isi) || !empty($replist)) {
		for($i=0;$i<sizeof($replist);$i++) {
			$v = $replist[$i];
			exec('c:\xampp\htdocs\bosms\gammu\gammu-smsd-inject.exe -c c:\xampp\htdocs\bosms\gammu\smsdrc EMS '.$v.' -text "'.$isi.'"');
		}
	}

  //mysql_query("UPDATE pesan SET pesan = '$_POST[pesan]', username='$_POST[user]' WHERE id_pesan = '$_POST[id]'");
  header('location:../../media.php?module='.$module);
}
}
?>
